package linc.spring.demo;

import linc.spring.demo.bean.UserFactoryBean;
import linc.spring.demo.config.ApplicationConfiguration;
import linc.spring.demo.service.UserService;
import lombok.SneakyThrows;
import org.junit.Test;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author yqlin
 * @date 2021/9/7 01:44
 * @description
 */
public class SprigFactoryBeanTest {
    @SneakyThrows
    @Test
    public void testFactoryBean() {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(ApplicationConfiguration.class);
        UserFactoryBean factoryBean = applicationContext.getBean(UserFactoryBean.class);
        System.out.println(applicationContext.getBean("&userFactoryBean"));
        System.out.println(applicationContext.getBean("userFactoryBean"));
        UserService userService = factoryBean.getObject();
        System.out.println(userService);
        userService.test();
    }
}
